// HSS.Net.Mail.EHelloCommand.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       EHelloCommand.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Net.Mail
{
	#region Using Directives
	using System;
	using System.Text;
	using System.IO;
	using System.Net.Sockets;
	using System.Net;
	using System.Net.Mail;
	using System.Diagnostics;
	using System.Collections;
	using System.Collections.Generic;
	#endregion

	static class EHelloCommand
	{
		static SmtpStatusCode statusCode = SmtpStatusCode.GeneralFailure;
		static string response = string.Empty;

		internal static void Send(SmtpConnection smtpConn)
		{
			EHelloCommand.PrepareCommand(smtpConn);
			smtpConn.Send();
			smtpConn.GetResponse(out statusCode, out response);

			if (statusCode != SmtpStatusCode.Ok)
				throw new SmtpException(statusCode, response);

		}
		private static void PrepareCommand(SmtpConnection smtpConn)
		{
			statusCode = SmtpStatusCode.GeneralFailure;
			response = string.Empty;

			smtpConn.Buffer.Append(SmtpCommands.EHello);
			smtpConn.Buffer.Append(string.IsNullOrEmpty(SmtpClient.DefaultHostName) ? System.Net.Dns.GetHostName() : SmtpClient.DefaultHostName);
			smtpConn.Buffer.Append(SmtpCommands.CRLF);
		}
	}
}